<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>货物运输管理</title>
<link rel="stylesheet" type="text/css" href="../jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="../jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="../jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
var url;
	function searchSpjin(){
		$('#dg').datagrid('load',{
			shangpinId:$('#s_shangpinId').combobox("getValue"),
			spcangkuId:$('#s_spcangkuId').combobox("getValue"),
			spgysId:$('#s_spgysId').combobox("getValue"),
			userId:$('#s_userId').combobox("getValue"),
			sdate:$('#s_sdate').datebox("getValue"),
			edate:$('#s_edate').datebox("getValue")
		});
	}
	
	function saveSpjin(){
		$("#fm").form("submit",{
			url:url,
			onSubmit:function(){
				return $(this).form("validate");
			},
			success:function(result){
			
				var s=result;
				var result = eval('(' + result + ')');
			
				if(result.errorMsg){
					$.messager.alert("系统提示",result.errorMsg);
					return;
				}else{
					$.messager.alert("系统提示","保存成功");
					resetValue();
					$("#dlg").dialog("close");
					$("#dg").datagrid("reload");
				}
			}
		});
	}

	function closeSpjinDialog(){
		$("#dlg").dialog("close");
		resetValue();
	}
	function openSpjinAddDialog(){
		$("#dlg").dialog("open").dialog("setTitle","添加货物运输");
		url="../addSpjin";
	}
	
	function resetValue(){
	}

	function openSpjinModifyDialog(){
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要编辑的数据！");
			return;
		}
		var row=selectedRows[0];
		$("#dlg").dialog("open").dialog("setTitle","编辑货物运输");
		$("#fm").form("load",row);
		url="../addSpjin?spjinId="+row.spjinId;
	}

	
	function datetostr(dateTime, row) {
		if(dateTime){
			var JsonDateValue = new Date(dateTime.time);
			var text = JsonDateValue.toLocaleString();
			return text;
		}else{
			return "未填写";
		}
	}

	function datetostr(date, row) {
		if(date){
			var date = new Date(date.time);
        	var y=date.getFullYear();
        	var m=date.getMonth()+1;
        	var d=date.getDate();
        	var h=date.getHours();
        	var m1=date.getMinutes();
        	var s=date.getSeconds();
        	m = m<10?("0"+m):m;
        	d = d<10?("0"+d):d;
        	return y+"-"+m+"-"+d;
			var text = JsonDateValue.toLocaleString();
			return text;
		}else{
			return "未填写";
		}
	}

</script>
</head>
<body style="margin: 5px;">
<!--startprint-->
	<table id="dg" title="货物运输" class="easyui-datagrid" fitColumns="true"
	 pagination="true" url="../getSpjins?spjinType=0" fit="true" toolbar="#tb">
		<thead>
			<tr>
				<th field="cb" checkbox="true"></th>
				<th field="spjinId" width="10">编号</th>
				<th field="userId" width="20" hidden="true">客户ID</th>
				<th field="userName" width="20">客户</th>
				<th field="shangpinId" width="20" hidden="true">货物ID</th>
				<th field="shangpinName" width="20">货物</th>
				<th field="sptypeId" width="20" hidden="true">范围ID</th>
				<th field="sptypeName" width="20">范围</th>
				<th field="spjinName" width="40">地址</th>
				<th field="spcangkuId" width="20" hidden="true">车辆ID</th>
				<th field="spcangkuName" width="20">车辆</th>
				<th field="spgysId" width="20" hidden="true">司机ID</th>
				<th field="spgysName" width="20">司机</th>
				<th field="spjinDate" width="20" formatter="datetostr">时间</th>
			</tr>
		</thead>
	</table>
	
	<div id="tb">
		<div>
			<a href="javascript:shenheSpjin()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">送达</a>
		</div>
		<div>
		&nbsp;时间：&nbsp;<input class="easyui-datebox" name="s_sdate" id="s_sdate" editable="false" size="10"/>->
		<input class="easyui-datebox" name="s_edate" id="s_edate" editable="false" size="10"/>
		&nbsp;货物：&nbsp;<input class="easyui-combobox" id="s_shangpinId" name="s_shangpinId"  data-options="panelHeight:'auto',editable:false,valueField:'shangpinId',textField:'shangpinName',url:'../shangpinComboList'"/>
		&nbsp;车辆：&nbsp;<input class="easyui-combobox" id="s_spcangkuId" name="s_spcangkuId"  data-options="panelHeight:'auto',editable:false,valueField:'spcangkuId',textField:'spcangkuName',url:'../spcangkuComboList'"/>
		&nbsp;司机：&nbsp;<input class="easyui-combobox" id="s_spgysId" name="s_spgysId"  data-options="panelHeight:'auto',editable:false,valueField:'spgysId',textField:'spgysName',url:'../spgysComboList'"/>
		&nbsp;客户：&nbsp;<input class="easyui-combobox" id="s_userId" name="s_userId"  data-options="panelHeight:'auto',editable:false,valueField:'userId',textField:'userName',url:'../userComboList'"/>
		<a href="javascript:searchSpjin()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		</div>
	</div>
	
	<div id="dlg-buttons">
		<a href="javascript:saveSpjin()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
		<a href="javascript:closeSpjinDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
	</div>

</body>
</html>